package com.qdlc.p2p.dal.dao.impl;


import java.util.List;

import javax.persistence.Query;

import org.springframework.stereotype.Service;

import com.qdlc.p2p.dal.common.dao.jpa.BaseDaoImpl;
import com.qdlc.p2p.dal.dao.EnjoyGoodsDao;
import com.qdlc.p2p.dal.dto.EnjoyGoods;

/**
 * Created by D on 2016/1/20.
 */
@Service("enjoyGoodsDao")
public class EnjoyGoodsDaoImpl extends BaseDaoImpl<EnjoyGoods> implements EnjoyGoodsDao {

    @Override
    public EnjoyGoods getEnjoyGoodsById(long id) {
        String jpql="from EnjoyGoods where id=?1";
        Query query = em.createQuery(jpql).setParameter(1,id);
        List<EnjoyGoods> list=query.getResultList();
        if (list != null && list.size() >= 0) {
            return list.get(0);
        } else {
            return null;
        }
    }

    @Override
    public List disablePosition(int prefecture) {
        String jpql="select position from EnjoyGoods where prefecture=?1";
        Query query = em.createQuery(jpql).setParameter(1,prefecture);
        List list=query.getResultList();
        return list;
    }

}
